/*
 * MIT License
 * 
 * Copyright (c) 2017 wen.gu <454727014@qq.com>
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/*****************************************************************************
 * Name:tiny_meta.h
 *
 * Purpose:  meta data API and data structure declaration
 *
 * Developer:
 * wen.gu,2016-05-09
 *
 *****************************************************************************/

#ifndef __TINY_META_H__
#define __TINY_META_H__

#include "general_type.h"

/***************************************************************************
 *
 * macro declaration
 *
 ***************************************************************************/ 

/***************************************************************************
 *
 * struct declaration
 *
 ***************************************************************************/

/***************************************************************************
 *
 * API declaration
 *
 ***************************************************************************/

/**
*@brief  create a meta data instance
*
*@param  meta [out] return the meta data instance 
*
*@return success:G_OK, fail: error code.
*@see
*/
GS32 tfMetaCreate(GPHD* meta);

/**
*@brief  destroy a meta data instance
*
*@param  meta [in] the meta data instance 
*
*@return none.
*@see
*/
void tfMetaDestroy(GPHD meta);

/**
*@brief  clear all item in meta data
*
*@param  meta [in] the meta data instance 
*
*@return None.
*@see
*/
void tfMetaClear(GPHD meta);

/**
*@brief  remove a item with the key
*
*@param  meta [in] the meta data instance
*@param  key  [in] the key of item
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaRemove(GPHD meta, GU32 key);

/**
*@brief  set data to meta data
*
*@param  meta [in] the meta data instance
*@param  key  [in] the key of item
*@param  type [in] the type of item
*@param  data [in] data pointer
*@param  size [in] data size
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaSetData(GPHD meta, GU32 key, GU32 type, const void* data, GU32 size);

/**
*@brief  find data from meta data
*
*@param  meta [in]  the meta data instance
*@param  key  [in]  the key of item
*@param  type [out] the type of item
*@param  data [out] data pointer
*@param  size [out] data size
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaFindData(GPHD meta, GU32 key, GU32* type, const void** data, GU32* size);
//////////////////////////////////////////////////////////////////////////

/**
*@brief  set a 32 bits integer to meta data
*
*@param  meta  [in] the meta data instance
*@param  key   [in] the key of item
*@param  value [in] the value of item
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaSetInt32(GPHD meta, GU32 key, GS32 value);

/**
*@brief  set a 64 bits integer to meta data
*
*@param  meta  [in] the meta data instance
*@param  key   [in] the key of item
*@param  value [in] the value of item
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaSetInt64(GPHD meta, GU32 key, GS64 value);

/**
*@brief  set a string to meta data
*
*@param  meta  [in] the meta data instance
*@param  key   [in] the key of item
*@param  value [in] the value of item
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaSetString(GPHD meta, GU32 key, const char* value);

/**
*@brief  set a float to meta data
*
*@param  meta  [in] the meta data instance
*@param  key   [in] the key of item
*@param  value [in] the value of item
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaSetFloat(GPHD meta, GU32 key, float value);

/**
*@brief  set a pointer to meta data
*
*@param  meta  [in] the meta data instance
*@param  key   [in] the key of item
*@param  value [in] the value of item
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaSetPointer(GPHD meta, GU32 key, const void* value);

/**
*@brief  set a boolean to meta data
*
*@param  meta  [in] the meta data instance
*@param  key   [in] the key of item
*@param  value [in] the value of item
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaSetBoolean(GPHD meta, GU32 key, GBOL value);

/**
*@brief  set a rectangle to meta data
*
*@param  meta  [in] the meta data instance
*@param  left  [in] left vertices
*@param  top   [in] top vertices
*@param  right [in] right vertices
*@param bottom [in] bottom vertices
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaSetRect(GPHD meta, GU32 key, 
                GS32 left, GS32 top, 
                GS32 right,GS32 bottom);

/**
*@brief  set a range value to meta data
*
*@param  meta  [in] the meta data instance
*@param  key   [in] the key of item
*@param  start [in] range start
*@param  end   [in] end of range
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaSetRange(GPHD meta, GU32 key, GS32 start, GS32 end);

//////////////////////////////////////////////////////////////////////////

/**
*@brief  find a 32 bits integer from meta data
*
*@param  meta  [in]  the meta data instance
*@param  key   [in]  the key of item
*@param  value [out] the value of item
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaFindInt32(GPHD meta, GU32 key, GS32* value);

/**
*@brief  find a 64 bits integer from meta data
*
*@param  meta  [in]  the meta data instance
*@param  key   [in]  the key of item
*@param  value [out] the value of item
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaFindInt64(GPHD meta, GU32 key, GS64* value);

/**
*@brief  find a string from meta data
*
*@param  meta  [in]  the meta data instance
*@param  key   [in]  the key of item
*@param  value [out] the value of item
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaFindString(GPHD meta, GU32 key, const char** value);

/**
*@brief  find a float from meta data
*
*@param  meta  [in]  the meta data instance
*@param  key   [in]  the key of item
*@param  value [out] the value of item
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaFindFloat(GPHD meta, GU32 key, float* value);

/**
*@brief  find a pointer from meta data
*
*@param  meta  [in]  the meta data instance
*@param  key   [in]  the key of item
*@param  value [out] the value of item
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaFindPointer(GPHD meta, GU32 key, const void** value);

/**
*@brief  find a boolean from meta data
*
*@param  meta  [in]  the meta data instance
*@param  key   [in]  the key of item
*@param  value [out] the value of item
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaFindBoolean(GPHD meta, GU32 key, GBOL* value);

/**
*@brief  find a rectangle from meta data
*
*@param  meta  [in] the meta data instance
*@param  key   [in]  the key of item
*@param  left  [out] left vertices
*@param  top   [out] top vertices
*@param  right [out] right vertices
*@param bottom [out] bottom vertices 
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaFindRect(GPHD meta, GU32 key, 
                GS32* left, GS32* top, 
                GS32* right,GS32* bottom);

/**
*@brief  find a range value from meta data
*
*@param  meta  [in]  the meta data instance
*@param  key   [in]  the key of item
*@param  start [out] range start
*@param  end   [out] end of range
*
*@return success: GTRUE, fail:GFALSE.
*@see
*/
GBOL tfMetaFindRange(GPHD meta, GU32 key, GS32* start, GS32* end);


#endif //end of __TINY_META_H__
 
